﻿import QtQuick 2.0
import "../components"
import QtCharts 2.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
Rectangle {
    width: parent.width
    height: parent.height
    property string defname: "5ml"
    property string defnamev: "6"
    property bool isdef: false
    property int number: 0
    property int typeid: 0
    property bool visb: false

    signal bt1()
    signal bt2()
    signal bt3()
    CustomPopupBoxWarning{
        id: syjx1
        box_text: "是否删除?"
        onAccepted: {
            bt3()
        }
    }


    Row{
        anchors.fill: parent

        // 名称
        CustomInputText{
            id: edit_name
            height: 40*dp; editWidth: visb?(parent.width - 280*dp)/2-15*dp:parent.width - 280*dp
            anchors.verticalCenter: parent.verticalCenter
            defaultText: defname
            prompt:{
                if(typeid===1){
                    return "请输入注射器类型(xml注射器)"
                }else if(typeid===2){
                    return "请输入盖类型"
                }else if(typeid===3){
                    return "请输入耗材类型"
                }
            }
            zsqflag: typeid===1
            inputMaxLength: 20
            lengthVisible:false
            onTextChanged: {
                CExeConfig.updatadeff(typeid,number,getText(),edit_namev.getText())
            }
        }
        Item{ height: 40*dp; width: 30*dp } // 占位
        CustomInputText{
            id: edit_namev
            visible: visb
            height: 40*dp; editWidth: (parent.width - 280*dp)/2-15*dp
            anchors.verticalCenter: parent.verticalCenter
            defaultText: defnamev
            inputMaxLength: 20
            intflag: typeid===3
            pdouflag: typeid===1
            lengthVisible:false
            onTextChanged: {
                CExeConfig.updatadeff(typeid,number,edit_name.getText(),getText())
            }
        }
        Item{
            visible: visb
            height: 40*dp; width: 30*dp } // 占位

        // 是否默认
        Item{
            height: parent.height; width: 100*dp
            CustomSwitchButton{
                height: 24*dp; width: 46*dp
                anchors.centerIn: parent
                id: button_autoExport
                checked: isdef
                CustomTooltip{
                    visible: parent.isHovered
                    text: "是否默认"
                }
                onClicked: {
                    if(isdef){
                        checked=true
                    }
                    bt1()
                }
            }
        }
        // 操作
        Item{
            height: parent.height; width: 150*dp
            Row{
                anchors.centerIn: parent
                spacing: 15*dp
                CustomButton{
                    width: 26*dp
                    height: 26*dp
                    icon_size: 23*dp
                    button_icon: "qrc:/picture/ph_add.png"
                    icon_color: "#999999"
                    icon_color_press: "#1677FF"
                    CustomTooltip{
                        visible: parent.isHovered
                        text: "添加"
                    }
                    onReleased: {
                        bt2()
                    }
                }
                CustomButton{
                    width: 26*dp
                    height: 26*dp
                    icon_size: 23*dp
                    button_icon: "qrc:/picture/ph_del.png"
                    icon_color: "#999999"
                    icon_color_press: "#1677FF"
                    CustomTooltip{
                        visible: parent.isHovered
                        text: "删除"
                    }
                    onReleased: {
                        syjx1.show()
                    }
                }
            }
        }



    }
    Rectangle{
        x:0*dp
        y:parent.height-2*dp
        height: 2*dp
        width: parent.width
        color: "#DEDEDE"
    }



}
